//---------------------------------------------------------------------
// <copyright file="BadAssociation.cs" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//---------------------------------------------------------------------

using System.Collections.Generic;
using Microsoft.Data.Edm.Library.Internal;
using Microsoft.Data.Edm.Validation;

namespace Microsoft.Data.Edm.Csdl.Internal.CsdlSemantics
{
    /// <summary>
    /// Represents a semantically invalid EDM association.
    /// </summary>
    internal class BadAssociation : BadElement, IEdmAssociation
    {
        private string namespaceName;
        private string name;

        public BadAssociation(string qualifiedName, IEnumerable<EdmError> errors)
            : base(errors)
        {
            qualifiedName = qualifiedName ?? string.Empty;
            EdmUtil.TryGetNamespaceNameFromQualifiedName(qualifiedName, out this.namespaceName, out this.name);
        }

        public string Name
        {
            get { return this.name; }
        }

        public string Namespace
        {
            get { return this.namespaceName; }
        }

        public IEdmAssociationEnd End1
        {
            get { return new BadAssociationEnd(this, "End1", this.Errors); }
        }

        public IEdmAssociationEnd End2
        {
            get { return new BadAssociationEnd(this, "End2", this.Errors); }
        }

        public CsdlSemanticsReferentialConstraint ReferentialConstraint
        {
            get { return null; }
        }
    }
}
